import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  UseGuards,
  Request,
  Query,
} from '@nestjs/common';
import { AgentManagService } from './agent_manag.service';
import { CreateAgentManagDto } from './dto/create-agent_manag.dto';
import {
  UpdateAgentManagDto,
  NewsPaginationParams,
} from './dto/update-agent_manag.dto';
import { JWT_User } from '../auth/dto/update-auth.dto';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
import { Permissions } from '../public/public.decorator';

@UseGuards(JwtAuthGuard)
@Controller('agent-manag')
export class AgentManagController {
  constructor(private readonly agentManagService: AgentManagService) {}

  @Post()
  create(@Body() createAgentManagDto: CreateAgentManagDto) {
    return this.agentManagService.create(createAgentManagDto);
  }

  @Get('getAgentRefundList')
  @Permissions('read')
  findAll(
    @Request() req: { user: JWT_User },
    @Query() query: NewsPaginationParams,
  ) {
    return this.agentManagService.findAll(query);
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.agentManagService.findOne(+id);
  }

  @Patch(':id')
  update(
    @Param('id') id: string,
    @Body() updateAgentManagDto: UpdateAgentManagDto,
  ) {
    return this.agentManagService.update(+id, updateAgentManagDto);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.agentManagService.remove(+id);
  }
}
